package com.haoze.nurseapp.controller;

import com.haoze.common.response.Result;
import com.haoze.common.response.ResultGenerator;
import com.haoze.nurseapp.annotation.NurseActionLog;
import com.haoze.nurseapp.service.TaskBatchService;
import com.haoze.nurseapp.service.TransfusionService;
import com.haoze.nurseapp.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


/**
 * 2020.07.03
 *
 * @author xmd
 */
@RestController
@RequestMapping(value = "/nurseapp/taskBatch")
@Api(value = "任务流执行")
public class TaskBatchController {

    @Resource
    TaskBatchService taskBatchService;

    @Resource
    TransfusionService transfusionService;

    @Resource
    UserService userService;

    @GetMapping("/infusionCenterList")
    @ApiOperation("输液中心-获取穿刺通道信息")
    @NurseActionLog("获取穿刺通道等输液信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "qrCode", value = "", dataType = "string", example = "", defaultValue = "")
    })
    public Result infusionCenterList(@RequestParam String qrCode) {
        return ResultGenerator.genOkResult(transfusionService.infusionCenterList(qrCode));
    }

    //
    @GetMapping("/writeFileAndCreateNextNode")
    @ApiOperation("根据类型回写当前文书并创建下一节点")
    @NurseActionLog("获取穿刺通道等输液信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "qrCode", value = "", dataType = "string", example = "", defaultValue = ""),
            @ApiImplicitParam(name = "actionName", value = "", dataType = "string", example = "", defaultValue = ""),
            @ApiImplicitParam(name = "saveSourceQrCode", value = "", dataType = "string", example = "", defaultValue = "", required = false),
            @ApiImplicitParam(name = "punctureChannleId", value = "", dataType = "string", example = "", defaultValue = "", required = false),
            @ApiImplicitParam(name = "changeType", value = "", dataType = "string", example = "", defaultValue = "", required = false)
    })
    public Result writeFileAndCreateNextNode(@RequestParam String qrCode, @RequestParam String actionName, @RequestParam(required = false) String saveSourceQrCode, @RequestParam(required = false) String punctureChannleId
            , @RequestParam(required = false) String changeType) {
        return taskBatchService.writeFileAndCreateNextNode(qrCode, actionName, saveSourceQrCode, punctureChannleId, changeType);
    }

    @GetMapping("/infusionCenterListByInpatNum")
    @ApiOperation("输液中心-通过住院号获取穿刺通道信息")
    @NurseActionLog("获取穿刺通道等输液信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "inpatNum", value = "住院号", dataType = "String", example = "1143026-1", defaultValue = "")
    })
    public Result queryInfusionCenterListByInpatNum(@RequestParam String inpatNum) {
        return taskBatchService.queryInfusionCenterList(inpatNum);
    }
}
